<?php
	####################################################
	# NArray                                           #
	####################################################

	#	example)
	#		$array_a = array();
	#		$array_b = array();
	#		$array_c = array();
	#		for($i=0; $i<=10; $i++){
	#			$array_a['키'.$i] = '값'.$i;
	#		}
	#		print_r($array_a);
	#		>>Array ( [키0] => 값0 [키1] => 값1 [키2] => 값2 [키3] => 값3 [키4] => 값4 [키5] => 값5 [키6] => 값6 [키7] => 값7 [키8] => 값8 [키9] => 값9 [키10] => 값10 )
	#
	#			print_r($array_b);
	#		>>Array ( [키0] => 값0 [키1] => 값1 [키2] => 값2 [키3] => 값3 [키4] => 값4 [키5] => 값5 [키6] => 값6 [키7] => 값7 [키8] => 값8 [키9] => 값9 [키10] => 값10 )
	#
	#		$array_c = copy_array_key($array_a, $array_c, array('키3','키6','키9'));
	#		print_r($array_c);
	#		>>Array ( [키0] => 값0 [키1] => 값1 [키2] => 값2 [키4] => 값4 [키5] => 값5 [키7] => 값7 [키8] => 값8 [키10] => 값10 )
	#
	#		$array_d = copy_array_val($array_a, $array_d, array('값1','값4','값8','값10'));
	#		print_r($array_d);
	#		>>Array ( [키0] => 값0 [키2] => 값2 [키3] => 값3 [키5] => 값5 [키6] => 값6 [키7] => 값7 [키9] => 값9 )

	class NArray {

		# 배열을 카피한다.
		public static function copy_array($original_array_name, $copy_array_name) {
			foreach($original_array_name as $key=>$val){
				$copy_array_name[$key] = $val;
			}
			return $copy_array_name;
		}

		# 해당 키는 삭제하고 배열을 카피한다.
		public static function copy_array_key($original_array_name, $copy_array_name, $clear_array_key) {
			for($i=0;$i<=count($clear_array_key);$i++){
				foreach($original_array_name as $key=>$val){
					if($clear_array_key[$i] != $key){
						$copy_array_name[$key] = $val;
					}else{
						$i++;
					}
				}
			}
			return $copy_array_name;
		}

		# 해당 값은 삭제하고 배열을 카피한다.
		public static function copy_array_val($original_array_name, $copy_array_name, $clear_array_val) {
			for($i=0;$i<=count($clear_array_val);$i++){
				foreach($original_array_name as $key=>$val){
					if($clear_array_val[$i] != $val){
						$copy_array_name[$key] = $val;
					}else{
						$i++;
					}
				}
			}
			return $copy_array_name;
		}

		# $delete_files = NArray::implode_separate($all); 로 form에서 넘기고
		#$arr_delete_files = NArray::explode_separate($req['delete_files']); 로 해체
		private static $separate_key = '|';

		# separate_key를 기준으로 explode
		public function explode_separate($array) {
			$ret = explode(NArray::$separate_key, $array);
			return $ret;
		}

		# separate_key를 기준으로 implode
		public function implode_separate($array) {
			$ret = implode(NArray::$separate_key, $array);
			return $ret;
		}

		# 배열 null 제거
		public static function array_notnull($arr) {
			if (!is_array($arr)) return;
			foreach ($arr as $k=>$v) if ($v=="") unset($arr[$k]);
			return $arr;
		}
	}
?>